<?php
namespace app\servermenu\validate;
use \app\manage\validate\BaseValidate;

class AdminMenu extends BaseValidate
{
    //验证规则
	protected $rule =   [
        'menu_cate_id' => ['integer', 'gt'=>'0'],
        'name' => ['alphaNum', 'length'=>'2,20'],
        'name_cn' => ['chsAlphaNum', 'length'=>'2,20'],
        'type' => ['in'=>['menu','button','nav']],
        'url' => ['url'],
        'merge_auth' => ['length'=>'4,128'],
        'auth_data' => ['regex'=>'^{.*}$'],
        'auth_id' => ['integer','gt'=>'0'],
        'pid' => ['integer', 'gt'=>'0'],
        'level' => ['integer', 'gt'=>'1'],
        'id' => ['integer', 'gt'=>'0'],
        'menu_id' => ['integer', 'gt'=>'0'],
        'role_id' => ['integer', 'gt'=>'0'],
        'parent_menu_id' => ['integer', 'gt'=>'0'],
        'role_ids' => ['min'=>'1', 'max'=>'256'],
    ];

    protected $message  =   [];

    protected $scene = [
        'get' => ['app_key'],
        'addShowMenuAuthByRole' => ['role_id', 'menu_id'],
        'addShowMenuAndChildren' => ['role_id', 'menu_id'],
        'addTop' => ['menu_cate_id', 'name', 'name_cn', 'order', 'type', 'url', 'merge_auth', 'auth_data', 'auth_id'],
        'add' => ['menu_cate_id', 'name', 'name_cn', 'order', 'type', 'merge_auth', 'auth_data', 'auth_id'],
        'stopShowMenuAuthByRole' => ['id', 'menu_id', 'role_id'],
        'startShowMenuAuthByRole' => ['id', 'menu_id', 'role_id'],
        'stopShowMenuAndChildren' => ['id', 'menu_id', 'role_id'],
        'startShowMenuAndChildren' => ['id', 'menu_id', 'role_id'],
        'treeByCate' => ['menu_cate_id'],
        'move' => ['id', 'pid'],
    ];

}